﻿using System;
using System.Collections.Generic;
using System.Linq;

using PortalIntranet.DatabaseComponents;
using PortalIntranet.DatabaseComponents.WebParts.Galerias;
using PortalIntranet.ObjectComponents.WebParts.Galerias;
using PortalIntranet.DatabaseComponents.WebParts;

namespace PortalIntranet.BusinessComponents.WebParts.Galerias
{
	public class GaleriasItensBll
	{
		public static GaleriaItem Obter(int id)
		{
			using (var contexto = new IntranetContexto())
			{
				return contexto.GaleriasItens
					.Where(c => c.Id == id
						&& !c.Desativado
						&& !c.Excluido)
					.SingleOrDefault();
			}
		}

		public static List<GaleriaItem> ListarGaleriasItens(int galeria)
		{
			using (var contexto = new IntranetContexto())
			{
				return contexto.GaleriasItens
					.Where(c => c.GaleriaId == galeria
						&& !c.Desativado
						&& !c.Excluido)
					.OrderBy(o => o.Ordem)
					.ToList();
			}
		}
	}
}
